package gui;

import java.awt.Component;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import javax.swing.JScrollPane;

public class ImagePane extends JScrollPane {
	private File file;
	private String fileName;

	public String getFileName() {
		return fileName;
	}

	public ImagePane(Component view, File file, String fileName) {
		super(view);
		this.file = file;
		this.fileName = fileName;
	}

	public ImagePane(File file, String fileName) {
		super();
		this.file = file;
		this.fileName = fileName;
	}

	public void save(File output) throws IOException {
		InputStream in = new FileInputStream(file);

		OutputStream out = new FileOutputStream(output);

		byte[] buf = new byte[1024];
		int len;
		while ((len = in.read(buf)) > 0) {
			out.write(buf, 0, len);
		}
		in.close();
		out.close();
	}
}
